class PostReqByDates extends PostsReq{

  String _startDate;
  String _endDate;

  PostReqByDates(Blog blog, String url, String startDate, String endDate):super(blog,url){
	_startDate = startDate;
	_endDate = endDate;
  }

	void loadNextPage(Queue nextPage){
	  String lastID = _blog.getLastID();
      if(lastID == null){
		window.alert("ERROR in loadNextPage: lastID == null");
     	  return;
	  }
	  
		Date sDate = new Date.fromString(_startDate);
		Date eDate = new Date.fromString(_endDate);
		String params = "?getpostsbetweendates=true&startdate="+sDate.value +"&enddate="+eDate.value + "&id=" + lastID;
		getPostsFromServer("GET", params, null, nextPage);
	}
	
	void loadPrevPage(Queue prevPage){
	  String firstID = _blog.getFirstID();
      if(firstID == null){
		    window.alert("ERROR in loadPrevPage: firstID == null");
     	  return;
	  }
		Date sDate = new Date.fromString(_startDate);
		Date eDate = new Date.fromString(_endDate);
		String params = "?getpostsbetweendates=true&prev=true&startdate="+sDate.value +"&enddate="+eDate.value + "&id=" + firstID;
		getPostsFromServer("GET", params, null, prevPage);
	}
	
	void loadCurrPage(Queue currPage){
		Date sDate = new Date.fromString(_startDate);
		Date eDate = new Date.fromString(_endDate);
		String params = "?getpostsbetweendates=true&startdate="+sDate.value +"&enddate="+eDate.value;
		getPostsFromServer("GET", params, null, currPage);
	}
  
}
